//页面白名单
const whiteList = [
    // '/pages/user/register',
    '/pages/user/login'
]
function hasPermission(url) {
    //请求路径在白名单中直接跳转，或者带有token直接跳转，
    var token = uni.getStorageSync('token')
    for (var i = 0; i < whiteList.length; i++) {
        /* || 或者带有token直接跳转 */
        if (url.indexOf(whiteList[i]) != -1 || token) {
            return true
        }
    }
    return false
}
uni.addInterceptor('navigateTo', {
    invoke(e) {
        if (!hasPermission(e.url)) {
            // uni.navigateTo({
            //     url: '/pages/user/register'
            // })
            return false
        }
        return true
    }, success(e) {
        console.log(e)
    }, fail(e) {
        console.log(e)
    }
})